<?php
// 日志级别 0为不输出 E_ALL输出所有
error_reporting(E_ALL);
/*调用实例*/
require_once("db_class.php"); //引入数据库类文件
/*实例化类：*/

function wow($type,$name,$num)
{
		$db=new mysql("127.0.0.1","root","sfwowchina","logon","conn","utf8");
/* 		if(!is_numeric($name))
		{
			echo "是字符串";
			exit;
		} */
		switch($type)
		{
//------------------------------------------------------------------------------------------------------------
			case 'online':
				//$sql = mysql_query("select a.id,a.last_ip,b.name from realmd.account a left join characters.characters b on a.id = b.account where b.online = '0'");
				$db->select_db("chars");
				$sql = mysql_query("SELECT account,name FROM `characters` WHERE `online` = '1' ORDER BY `account`");
				if(!$sql)
				{
					echo "没有玩家在线!";
					exit;
				}
				else
					{
						while($row=mysql_fetch_array($sql))
						{
							echo $row['account']."&nbsp;&nbsp;&nbsp;".$row['name'];
							echo "<br>";
						}
						printf("游戏在线人数: %d\n", mysql_affected_rows());
						
					}
					break;
//------------------------------------------------------------------------------------------------------------
			case 'addjf':
				$sql = mysql_query("INSERT INTO chars._ck_recharge (acct,time,balance) select id,NOW(),'".$num."' from logon.account where username = '".$name."'");
					echo "充值成功!!!";
					break;
//------------------------------------------------------------------------------------------------------------
			case 'addgm':
				$sql = mysql_query("INSERT INTO logon.account_access (`id`,`gmlevel`,`RealmID`) select id,3,-1 from logon.account where username = '".$name."'");
					echo "管理员添加成功!!!";
					break;
//------------------------------------------------------------------------------------------------------------
			case 'logon':
				$ip=$db->getip();
				$sql = mysql_query("UPDATE logon.`realmlist` SET `address`='".$ip."',name='".$name."' WHERE (`id`='1')");
					echo "外网ip已经改成:".$ip."";
					echo "<br>如果是路由器上网,请映射所有端口到您开游戏的电脑上!!!";
					break;
//------------------------------------------------------------------------------------------------------------
			case 'viper':
				$ip=$db->getip();
				$sql = mysql_query("UPDATE chars.`_ck_members` SET `viplevel`='".$num."' where acct in(select id from logon.account where username = '".$name."')");
					echo "账户下线才可以修改会员级别成功!!!";
					break;


		}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>Welcome</TITLE>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>
 <BODY>
<form name="input" action="ckwow_admin.php" method="get">
账户/游戏名字
<input type="text" name="name" />
积分数/会员级别
<input type="text" name="num" />
<select name="type" class="textarea">
<option selectd value="online">人数</option>
<option value="addjf">加积分</option>
<option value="addgm">加管理</option>
<option value="logon">改外网</option>
<option value="viper">改会员</option>
<input type="submit" value="执行" />
</form>
<?
if(isset($_GET['name']) && isset($_GET['type']))
{
	$name =$_GET['name'];
	$num =$_GET['num'];
	$type =$_GET['type'];
	wow($type,$name,$num);
}
else
{
	echo "Welcome!";
}
?>
 </BODY>
</HTML>